﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using _MetalSlug.MyCharacters.Characters.Guns;
using System.Xml;

namespace _MetalSlug.Mementoes
{
    public class GunMemento : IMemento
    {
        Gun.TYPE type;
        public Gun.TYPE Type
        {
            get { return type; }
        }

        int bulletCount;
        public int BulletCount
        {
            get { return bulletCount; }
        }

        public GunMemento(Gun RepresentGun)
        {
            type = RepresentGun.TypeOfGun;
            bulletCount = RepresentGun.CountBullet;
        }

        public GunMemento(XmlElement Element)
        {
            type = (Gun.TYPE)Enum.Parse(typeof(Gun.TYPE), Element.GetAttribute("Type"));
            bulletCount = int.Parse(Element.GetAttribute("BulletCount"));
        }

        public XmlElement ToXML(XmlDocument Doc)
        {
            XmlElement Element = Doc.CreateElement("Gun");
            Element.SetAttribute("Type",Type.ToString());
            Element.SetAttribute("BulletCount", BulletCount.ToString());
            return Element;
        }
    }
}
